package com.xiaoyao.novel.dao;

import java.sql.SQLException;
import java.util.List;

import javax.annotation.Resource;
import javax.management.relation.Role;

import com.xiaoyao.novel.pojo.User;
 
/**
 * @author 旷明爱
 * @date 2013-6-13 下午02:22:27
 */
@SuppressWarnings("unchecked")
public class UserDao  extends BaseDao<User>{
	
	
	
	public User getByAcountPass(User user) throws SQLException {
		return (User) session.queryForObject(PREFIX + "getByAcountPass", user);
	}

	public List<Resource> getResourceByUserId(int userId) throws SQLException {
		return (List<Resource>) session.queryForList(PREFIX + "getResourceByUserId", userId);
	}

	public Role getRoleByUserId(int userId) throws SQLException {
		return (Role) session.queryForObject(PREFIX + "getRoleByUserId", userId);
	}

	// //////////////////////////////////////
 

	public static void main(String[] args) throws Exception {
		UserDao userDao = new UserDao();
		User user = new User();
		 
		userDao.insert(user);
		System.out.println(user);
		user = userDao.getByAcountPass(user);
	}
  

	public void deleteUserRole(String userId) throws SQLException {
		session.delete(PREFIX + "deleteUserRole", userId);
	}
 

}
